const { DataTypes } = require('sequelize');

module.exports = function Floorplan(sequelize, namespace = '') {
	sequelize.define('Floorplan', {
		id: {
			type: DataTypes.INTEGER,
			allowNull: false,
			autoIncrement: true,
			primaryKey: true
		},
		fpid: {
			type: DataTypes.CHAR(32),
			allowNull: false
		},
		version: DataTypes.STRING,
		createdBy: {
			type: DataTypes.STRING
		},
		platform: {
			type: DataTypes.INTEGER
		},
		compassAngle: {
			type: DataTypes.FLOAT,
			defaultValue: 0
		},
		drawing: {
			type: DataTypes.CHAR(24)
		},
		remark: {
			type: DataTypes.STRING,
			defaultValue: null
		},
		modelId: {
			type: DataTypes.STRING
		},
		modelVersion: {
			type: DataTypes.STRING
		},
		// 组织
		organization: {
			type: DataTypes.STRING
		},
		organizationName: {
			type: DataTypes.STRING
		},
		//所属系统
		system: {
			type: DataTypes.STRING
		},
		createdAt: {
			type: DataTypes.DATE
		},
		updatedAt: {
			type: DataTypes.DATE
		},
		deletedAt: {
			type: DataTypes.DATE
		}
	}, {
		indexes: [{
			unique: true,
			name: 'idx_fpid',
			fields: ['fpid']
		}],
		tableName: `${namespace}floorplan`
	});
};